import { createRouter, createWebHashHistory } from 'vue-router'
import menuArr from './menu.js'
import Layout from '@/views/LayoutView.vue'
import LoginView from '@/views/LoginView.vue'
import NotFound from '@/views/NotFound.vue'

const routes = [
  {
    path: '/',
    name: 'layout',
    component: Layout,
    meta: {
      // 标记当前页面是否需要登录权限
      requireLogin: true,
    },
    redirect: 'main',
    children: [...menuArr],
  },
  {
    path: '/login',
    name: 'login',
    title: '登录',
    meta: {
      // 标记当前页面是否需要登录权限
      requireLogin: false,
    },
    component: LoginView,
  },
  { path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound },
]
const router = createRouter({
  history: createWebHashHistory(),
  routes: routes,
})

export default router
